package com.ljb.irouter.model;

import javax.lang.model.element.Element;

public class IRouterBean {

    public enum TYPE {
        IRouterCall,
        IRouterInterceptor
    }

    public static IRouterBean create(TYPE type, Class<?> clazz, String path, String group) {
        return new IRouterBean(type, clazz, path, group);
    }


    private TYPE type;
    private Element element;
    private Class<?> clazz;
    private String path;
    private String group;

    private IRouterBean(Builder builder) {
        element = builder.element;
        path = builder.path;
        group = builder.group;
    }

    private IRouterBean(TYPE type, Class<?> clazz, String path, String group) {
        this.type = type;
        this.clazz = clazz;
        this.path = path;
        this.group = group;
    }

    public TYPE getType() {
        return type;
    }

    public String getPath() {
        return path;
    }

    public String getGroup() {
        return group;
    }

    public Element getElement() {
        return element;
    }

    public Class<?> getClazz() {
        return clazz;
    }

    public final static class Builder {
        private Element element;
        private String path;
        private String group;

        public Builder setGroup(String group) {
            this.group = group;
            return this;
        }

        public Builder setElement(Element element) {
            this.element = element;
            return this;
        }


        public Builder setPath(String path) {
            this.path = path;
            return this;
        }

        public IRouterBean build() {
            if (path == null || path.length() == 0) {
                throw new IllegalArgumentException("not found path!");
            }
            return new IRouterBean(this);
        }
    }


}
